﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DafYomiPortalLib
{
    using DafYomiLib;

    public class Rabbi : IEquatable<Rabbi>
    {
        public bool Equals(Rabbi other)
        {
            if (ReferenceEquals(null, other)) return false;
            if (ReferenceEquals(this, other)) return true;
            return Id == other.Id && 
                string.Equals(Name, other.Name) &&
                string.Equals(GivesLessonsInLanguage, other.GivesLessonsInLanguage);
        }

        public override bool Equals(object obj)
        {
            if (ReferenceEquals(null, obj)) return false;
            if (ReferenceEquals(this, obj)) return true;
            if (obj.GetType() != this.GetType()) return false;
            return Equals((Rabbi) obj);
        }

        public override int GetHashCode()
        {
            unchecked
            {
                var hashCode = Id;
                hashCode = (hashCode*397) ^ (Name != null ? Name.GetHashCode() : 0);
                hashCode = (hashCode*397) ^ (GivesLessonsInLanguage != null ? GivesLessonsInLanguage.GetHashCode() : 0);
                return hashCode;
            }
        }

        public Rabbi(string id, string name, string language)
        {
            Id = Convert.ToInt16(id);
            Name = name;
            GivesLessonsInLanguage = language;
        }

        public int Id { get; private set; }

        public string Name { get; private set; }

        public string GivesLessonsInLanguage { get; private set; }

        public override string ToString()
        {
            return Name;
        }

    }
}
